package cn.maihe.elg.operation.service.facade;

import cn.maihe.elg.operation.model.dto.BaseResp;
import cn.maihe.elg.operation.model.dto.InnerBaseResp;
import cn.maihe.elg.operation.model.dto.institution.PushGuaranteeRespDTO;
import cn.maihe.elg.operation.service.order.ApplyOrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description 订单-出函机构交互
 * @Author WJH
 * @Date 2021/05/11
 */
@Service
@Slf4j
public class OrderInstitutionCallbackService {

    @Resource
    private ApplyOrderInfoService applyOrderInfoService;

    /**
     * 接收出函机构 推送的电子保函服务
     *
     * @return
     */
    public InnerBaseResp<BaseResp> institutionPushGuarantee(InnerBaseResp<PushGuaranteeRespDTO> resp) {
        if (resp.getRespCode().isSuccess()) {
            //1.保存电子保函签章文件 2.更新我的申请保函以及我的受理保函状态
            applyOrderInfoService.receivePushGuaranteeSuccess(resp.getData(),false);
        } else {
            // 2.更新我的申请保函以及我的受理保函状态 FIXME 出函失败处理业务？？
        }

        return InnerBaseResp.success(null);
    }


}
